<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=7" />
	<title>“半价汇”广告管理系统</title>
	<!-- Reset Stylesheet -->
	<link rel="stylesheet" href="static/css/reset.css" type="text/css" media="screen" />
  
	<!-- Main Stylesheet -->
	<link rel="stylesheet" href="static/css/style.css" type="text/css" media="screen" />
	
	<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
	<link rel="stylesheet" href="static/css/invalid.css" type="text/css" media="screen" />	
	<link rel="stylesheet" type="text/css" media="screen" href="static/css//datePicker.css">

	<script type="text/javascript" src="static/js/jquery.min.js"></script>
	<!-- jQuery Configuration -->
	<script type="text/javascript" src="static/js/simpla.jquery.configuration.js"></script>

	<script type="text/javascript" src="static/js/date.js"></script>
	<script type="text/javascript" src="static/js/jquery.datePicker.js"></script>

	<script type="text/javascript" src="static/js/jquery.metadata.js"></script>
	<script type="text/javascript" src="static/js/jquery.validate.min.js"></script>
</head>
<style>
/* located in demo.css and creates a little calendar icon
 * instead of a text link for "Choose date"
 */
a.dp-choose-date {
	float: left;
	width: 16px;
	height: 16px;
	padding: 0;
	margin: 5px 3px 0;
	display: block;
	text-indent: -2000px;
	overflow: hidden;
	background: url(static/images/calendar.png) no-repeat; 
}
a.dp-choose-date.dp-disabled {
	background-position: 0 -20px;
	cursor: default;
}
/* makes the input field shorter once the date picker code
 * has run (to allow space for the calendar icon
 */
input.dp-applied {
	width: 140px;
	float: left;
}
</style>
<body>
	<div id="body-wrapper">
		<?php include 'admin_sidebar.html'; ?>
		<div id="main-content">
			<div class="content-box">
				<div class="content-box-header">
					<h3>修改店铺</h3>
					<div class="clear"></div>
				</div>
				<div class="content-box-content">
				<form action="<?php echo spUrl('store', 'edit');?>" method="post" enctype="multipart/form-data" id="store_edit">
				<input type="hidden" name="store_id" id="store_id" value="<?php echo $result[store_id];?>">
				<fieldset>
					<p>
						<label>店铺卖家姓名：</label>
						<input type="text" name="nickname" id="nickname" class="text-input small-input" value="<?php echo $result[nickname];?>"/>
					</p>
					<p>
						<label>店铺名称：</label>
						<input type="text" name="store_name" id="store_name" class="text-input small-input" value="<?php echo $result[store_name];?>"/>
					</p>
					<p>
						<label>店铺类目：</label>
						<select name="cid" id="cid">
							<?php foreach($arr_cid as $cid=>$cname) { ?>
							<option value="<?php echo $cid; ?>" <?php if($cid == $result['cid']) echo 'selected'; ?>><?php echo $cname; ?></option>
							<?php } ?>
						</select>
					</p>
					<p>
						<label>店铺类型：</label>
						<input type="radio" name="type" value="C" <?php if($result[type]=='C') {echo 'checked';} ?> />C店<br />
						<input type="radio" name="type" value="B" <?php if($result[type]=='B') {echo 'checked';} ?>/>B店
					</p>
					<p>
						<label>分类：</label>              
						<select name="catid" validate="required:true">
							<option value="">请选择</option>
							<?php foreach($arr_cat as $k=>$v) {?>
							<option value="<?php echo $k; ?>" <?php if($k == $result['catid']) echo 'selected'; ?>><?php echo $v; ?></option>
							<?php } ?>
						</select>
						<br /><small>不能为空</small>
					</p>
					<!-- <tr>
						<th>阿里妈妈链接：</th><td><input type="text" name="alimama_url" id="alimama_url" size="50" /></td>
					</tr> -->
					<p>
						<label>店铺阿里妈妈链接：</label>
						<input type="text" name="alimama_url" id="alimama_url" class="text-input medium-input" value="<?php echo $result[alimama_url];?>"/>
					</p>
					<p>
						<label>等级：</label>              
						<select name="store_level">
							<option value="">请选择</option>
							<option value="A" <?php if('A' == $result['store_level']) echo 'selected'; ?>>A类</option>
							<option value="B" <?php if('B' == $result['store_level']) echo 'selected'; ?>>B类</option>
						</select>
					</p>
					<p>
						<input type="submit" value="确定" class="button" style="width: 105px;" /> <input type="reset" style="width: 45px;" class="button">
					</p>
				</fieldset>
				</form>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$('#nickname').blur(function(){
	$.getJSON("<?php echo spUrl('store', 'getAjax_sidAndAlimamaurl');?>", {store_name:$('#nickname').val(),store_id:$('#store_id').val()}, function(data){
		if(data) {
			if(data == '-1') {
				alert('该店铺已经存在');
			} else if(data == '-2') {
				alert('该用户没有店铺');
			} else {
				$('#store_id').val(data.sid);
				$('#cid').val(data.cid);
				$('#alimama_url').val(data.alimama_url);
				$('#store_name').val(data.title);
				$("input[name='type'][value="+data.type+"]").attr("checked",'checked');
			}
		}
		return false;
	});
})

$.metadata.setType("attr", "validate");

$().ready(function() {
	$("#store_edit").validate({
		rules:{
			nickname: {
				required:true,
				minlength:2
			},
			store_name: "required",
			alimama_url:"required"
		}
	});
});
</script>
</html>